package com.salestax.core.main;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import com.salestax.core.ShoppingList;
import com.salestax.core.io.ShoppingListReader;
import com.salestax.core.visitor.ReceiptPrinter;
import com.salestax.core.visitor.ShoppingListVisitor;

public class MainTest {
	
	public static void main(String[] args) throws IOException {
		if(args.length < 2){
			System.out.println("At least two arguments are required");
			System.out.println("First is input file");
			System.out.println("Second is output file");
			System.exit(1);
		}
		//String inputFile = "C:\\list-1.txt";
		String inputFile = args[0];
		//String outputFile = "C:\\rece-1.txt";
		String outputFile = args[1];
		
		FileReader reader = new FileReader(inputFile);
		FileWriter writer = new FileWriter(outputFile);
		ShoppingListReader shoppingListReader = new ShoppingListReader(reader);
		ShoppingList list = shoppingListReader.getShoppingListFromReader();
		reader.close();

		ShoppingListVisitor visitor = new ReceiptPrinter(writer);
		visitor.visit(list);
		
		writer.close();
	}

}
